<?php
/**
 * 显示评测结果
 *
 * @todo 支持ajax
 * @author Judas <judasnow@gmail.com>
 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
 */
session_start();
require_once('path.php');
require_once( SOJ_ROOT.'/include/function/lib.php');

require_once('Pager.php');

$tpl = new my_smarty();

if( !empty($_SESSION['username']) ){

	$tpl->assign( 'username' , $_SESSION['username'] );

}

try{

	$db = db_connect();
	
	$judge_result_proc = new judge_result_process( $db );
	$results = $judge_result_proc->get_all_result();

	//取出一组数据用来生成标题
	$titles = array_keys( $results[0] );

	$params = array(
    		'itemData' => $results,
    		'perPage' => 30,
    		'delta' => 8,             
    		'append' => true,
    		'clearIfVoid' => false,
    		'urlVar' => 'entrant',
    		'useSessions' => true,
    		'closeSession' => true,
    		'mode'  => 'Jumping',
	);
	
	$pager = & Pager::factory($params);
	$page_data = $pager->getPageData();
	$links = $pager->getLinks();

	$tpl->assign( 'titles' , $titles ) ;
	
	$tpl->assign( 'results' , $page_data ) ;

	$tpl->assign( 'links' , $links['all'] );

	$tpl->display('judge_result.tpl') ;

}catch(Exception $e){

	exception_handle( $e );
}
